let now_page_banner = 0;
let box_items_a = document.getElementsByClassName("box-items-a")[0];
let box_items_a_li = box_items_a.getElementsByTagName("li");
// 获取轮播图 小按钮
let box_items_btn_b1 = document.getElementsByClassName("box-items-btn-b1")[0];
let box_items_btn_b1_a = box_items_btn_b1.getElementsByTagName("a");
// 定时器的时间
let s=3000;
function prev() {
	var old_page_num = now_page_banner; //0   1  2
	now_page_banner = prev_page(now_page_banner); //1 第二张图  2  0
	chang_page(now_page_banner, old_page_num);
}

function next() {
	console.log(1);
	var old_page_num = now_page_banner; //0   1  2
	now_page_banner = next_page(now_page_banner); //1 第二张图  2  0
	chang_page(now_page_banner, old_page_num);
}

function chang_page(now_page_banner, old_page_num) {
	for (let i = 0; i < box_items_a_li.length; i++) {
		// if (i != now_page_banner || i != old_page_num) {
			box_items_a_li[i].className = "";
		// }
	}
	box_items_a_li[now_page_banner].className = "change_banner_new"; //1  2  0
	box_items_a_li[old_page_num].className = "change_banner_old"; //0  1  2
	for (let i = 0; i < box_items_btn_b1_a.length; i++) {
		box_items_btn_b1_a[i].className = "";
	}
	box_items_btn_b1_a[now_page_banner].className = "active";
}

function prev_page(n) {
	n--;
	if (n < 0) {
		n = box_items_a_li.length - 1;
	}
	return n;
}

function next_page(n) {
	n++;
	if (n > box_items_a_li.length - 1) {
		n = 0;
	}
	return n;
}
// 轮播图定时器
var timer = setInterval(next(), s)
// var timer = setInterval(function() {
// 	next();
// }, 6000)
// 点击轮播图小按钮 切图
function change_banpage_num(new_n) {
	// 轮播图定时器 清除
	clearInterval(timer);

	for (let i = 0; i < box_items_a_li.length; i++) {
		if (i != now_page_banner || i != new_n) {
			box_items_a_li[i].className = "";
		}
	}
	box_items_a_li[new_n].className = "change_banner_new";
	box_items_a_li[now_page_banner].className = "change_banner_old";
	now_page_banner = new_n;
	for (let i = 0; i < box_items_btn_b1_a.length; i++) {
		box_items_btn_b1_a[i].className = "";
	}
	box_items_btn_b1_a[now_page_banner].className = "active";
	// 轮播图定时器
	 timer = setInterval(next(), s)
}

	
	for(let i=0;i<box_items_btn_b1_a.length;i++){
		box_items_btn_b1_a.onmouserover=function(){
			clearInterval(timer)
		}
		box_items_btn_b1_a.onmouserout=function(){
			timer = setInterval(next(), s)
		}
	}
	
	
